package com.sam.im.heiqun.uis.activities;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.annotation.Nullable;
import android.util.Log;
import android.view.WindowManager;

import com.sam.im.heiqun.R;
import com.sam.im.heiqun.constant.Constant;
import com.sam.im.heiqun.entities.UserEntivity;
import com.sam.im.heiqun.nets.PGService;
import com.sam.im.heiqun.utils.ToolsUtils;
import com.yuyh.library.utils.data.PrefsUtils;


public class StartActivity extends Activity {

    private static final int DO_SOME_THING = 1000;

    private PGService mPgService;


    private Handler handler = new Handler() {
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            initViews();
        }
    };
    private UserEntivity userEntivity;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        setContentView(R.layout.activity_start);
        handler.sendEmptyMessageDelayed(DO_SOME_THING, 2000);

        int ii = 8 /2;
        Log.e("",ii+"");
    }

    protected void initViews() {
        mPgService = PGService.getInstance();
        userEntivity = ToolsUtils.getUser();
        if (userEntivity == null||!ToolsUtils.saveLoginstate(this,false,2)) {
            String isFirst = new PrefsUtils(this, Constant.IS_FIRST).get(Constant.IS_FIRST, "");
//            if ("".equals(isFirst)) {
//                startActivity(new Intent(this, HelloMobileYXActivity.class));
//            } else {
                startActivity(new Intent(this, LoginActivity.class));
//            }
            finish();
        } else {
                ToolsUtils.doLogin(mPgService, userEntivity.getMobilePrefix(), this, userEntivity.getMobile(), userEntivity.getPassword());
        }
    }

}
